﻿Public Class EnglishUSKeyboard

    Inherits System.Windows.Forms.TextBox
    Private EscapeFlag As Boolean   ' Set when user presses the back slash \
    Private mTypingStyle As String
    Private LastCh As String

    Protected Overrides Function ProcessKeyMessage(ByRef m As System.Windows.Forms.Message) As Boolean
        If m.Msg <> 258 Then Return False
        Const Delay As Integer = 100
        ' Obtain the Keystroke character
        Dim KeyChar As Integer = m.WParam.ToInt32

        Dim dv As New DataView()
        Try
            dv.Table = frmMain.ds.Tables(frmMain.DictTable)
            If frmMain.checkWord1.Checked = True Then
                dv.RowFilter = "Words like '%" & Me.Text & "%'"
                frmMain.listWords.DataSource = dv
            ElseIf frmMain.checkWord2.Checked = True Then
                dv.RowFilter = "Transcription like '%" & Me.Text & "%'"
                frmMain.listWords.DataSource = dv
            End If

            If KeyChar = Keys.Enter Then
                If frmMain.checkWord1.Checked = True Then
                    frmMain.SearchWords(frmMain.DictTable, "Words", Me.Text)
                ElseIf frmMain.checkWord2.Checked = True Then
                    frmMain.SearchWords(frmMain.DictTable, "Transcription", Me.Text)
                End If
            End If
        Catch
            Me.Text = Me.Text
        Finally

        End Try
    End Function

End Class
